<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>员工管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body class="layui-anim layui-anim-up">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">员工管理</a>
        <a>
          <cite>员工列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
          <input class="layui-input" placeholder="开始日" name="start" id="start">
          <input class="layui-input" placeholder="截止日" name="end" id="end">
          <input type="text" name="username"  placeholder="请输入员工用户名" autocomplete="off" class="layui-input">
          <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加用户','./employeeAdd.html',800,500)">
        	<i class="layui-icon"></i>添加员工
        </button>
        <span class="x-right" style="line-height:40px">共有数据：2 条</span>
      </xblock>
      <!--数据表格-->
      <table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
    </div>
    <script>
        layui.use(['element', 'table', 'form', 'jquery', 'laydate'], function() {
            var element = layui.element;
            var table = layui.table;
            var form = layui.form;
            var $ = layui.jquery;
            var laydate = layui.laydate;
            laydate.render({
                elem: '#startTime',
                type: "datetime"
            });
            laydate.render({
                elem: '#endTime',
                type: "datetime"
            });
            table.render({
                elem: '#tableId',
                url: "http://admin.516code.cn/backstage/queryAllPersonnel.do",
                limit: 10,
                page: true,
                even: true,
                cols: [
                    [{
                        type: 'checkbox'
                    }, {
                        field: 'personnelId',
                        title: '员工编号',
                        width: 160,
                        sort: true
                    }, {
                        field: 'personnelAccount',
                        title: '员工账号',
                        width: 160
                    }, {
                        field: 'personnelPwd',
                        title: '员工密码',
                        width: 160
                    }, {
                        field: 'personnelName',
                        title: '员工姓名',
                        width: 160
                    }, {
                        field: 'personnelImg',
                        title: '员工头像',
                        width: 160
                    }, {
                        field: 'personnelType',
                        title: '职位类型',
                        width: 160
                    }, {
                        title: '操作',
                        width: 250,
                        templet: '#operationTpl',
                        align: 'center'
                    }]
                ],
                done: function(res, curr, count) {
                    $("#countNum").text(count);
                }
            });
            form.on('submit(search)', function() {
                layer.msg('正在查询，请稍后...');
                return false;
            });
            table.on('tool(tableFilter)', function(obj) {
                var data = obj.data;
                var layEvent = obj.event;
                if (layEvent === 'update') {
                    layer.open({
                        title: '修改员工信息',
                        type: 2,
                        shade: false,
                        maxmin: true,
                        shade: 0.5,
                        area: ['60%', '80%'],
                        content: 'employeeUpdate.html',
                        zIndex: layer.zIndex,
                        success: function(layero, index) {
                            console.log(data);
                            var body = layui.layer.getChildFrame('body', index);
                            if (data) {
                                body.find(".personnelId").val(data.personnelId);
                                body.find(".personnelAccount").val(data.personnelAccount);
                                body.find(".personnelName").val(data.personnelName);
                                body.find(".personnelPwd").val(data.personnelPwd);
                                body.find(".personnelImg").val(data.personnelImg);
                                body.find(".personnelType").val(data.personnelType);
                            }
                        },
                        end: function() {
                            $(".layui-laypage-btn")[0].click();
                        }
                    });
                } else if (layEvent === 'del') {

                }
            });
        })
    </script>
    <script type="text/javascript" src="js/jquery-1.4.1.js" ></script>

  </body>

  <script type="text/html" id="operationTpl">
    <a href="javascript:;" title="修改" lay-event="update"><i class="layui-icon">&#xe642;</i></a>
    <a title="删除" onclick="member_del(this,'要刪除的id')" href="javascript:;">
      <i class="layui-icon">&#xe640;</i>
    </a>
  </script>

  <script type="text/javascript">
      /*员工-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $(obj).parents("tr").remove();
              layer.msg('已删除!',{icon:1,time:1000});
          });
      }

      function delAll (argument) {

          var data = tableCheck.getData();

          layer.confirm('确认要删除吗？'+data,function(index){
              //捉到所有被选中的，发异步进行删除
              layer.msg('删除成功', {icon: 1});
              $(".layui-form-checked").not('.header').parents('tr').remove();
          });
      }
  </script>
</html>